//
// Created by 30938 on 2022/8/30.
//

#include <iostream>
#include <list>

using namespace std;

size_t remove_element_if_great_than(list<long>& longList,long IThredhold){
    int cnt=0;
    for(auto it=longList.begin();it!=longList.end();){
        if(*it>IThredhold) {
            it=longList.erase(it);

            cnt++;
        }else{
            ++it;
        }
    }
    return cnt;
}

void test01(){

    list<long> _list={1,2,3,4,5,6,7,8,9};
    cout<<remove_element_if_great_than(_list,7)<<endl;
    for(auto elem:_list){
        cout<<elem<<" ";
    }
}

int main(){
    test01();
    return 0;
}
